﻿namespace EyeOpen.Validation
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Runtime.Serialization;

    public class ValidationException : Exception
    {
        public ValidationException() 
            : this(string.Empty)
        {
        }

        public ValidationException(string message) 
            : base(message)
        {
        }

        public ValidationException(string message, Exception innerException)
            : base(message, innerException)
        {
        }

        public ValidationException(IEnumerable<ValidationResult> validationResults)
        {
            if (validationResults == null)
            {
                throw new ArgumentNullException("validationResults");
            }

            if (validationResults.Count() == 0)
            {
                throw new ArgumentOutOfRangeException("validationResults");
            }

            ValidationResults = validationResults;
        }

        protected ValidationException(SerializationInfo info, StreamingContext context)
            : base(info, context)
        {
        }

        public IEnumerable<ValidationResult> ValidationResults
        {
            get; 
            private set;
        }
    }
}
